$(function () {
  ProjectCard = 1;
  initProjectCardData()
})
function initProjectCardData() {
  //项目库 统计模块
  rwhdetaile()
  //成本明细
  getcostBreakdownData()
  if (tabIndex == 0) {
    JHSR()
  }
  if (tabIndex == 1) {
    NDSJ()
  }
  if (tabIndex == 2) {
    EMS()
  }
  if (tabIndex == 3) {
    JHZC()
  }
  if (tabIndex == 4) {
    SJZC()
  }
  $(".ProjectCard-content h3").text( localStorage.getItem('rwhText')== '' ? '全部' : localStorage.getItem('rwhText').split('    '))
}
function rwhdetaile() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    status: 2,
    chartPage: 80804,
    chartNo: 1,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data,'项目库 统计模块')
    if (data.length > 0) {
      let options = ''
      options += `
             <!-- 左边卡片 -->
              <div>
                <div class="item">
                  <div>
                    <p>合同个数</p>
                    <div class="dw"> <span class="num">${data[0].key01}</span> 个 </div>
                  </div>
                </div>
                <div class="item" style="padding:16px 0 0 0;border-bottom: none; ">
                  <div>
                    <p>合同总额</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key02)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>收款总额</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key03)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>开票总额</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key04)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>计提收益</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key05)}</span> 万元 </div>
                  </div>
                </div>
              </div>
              <!-- 右边卡片 -->
              <div>
                <div class="item">
                  <div>
                    <p>计划收入</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key06)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>计划成本</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key07)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>计划收支比</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key08)}</span> % </div>
                  </div>
                </div>
                <div class="item" style="padding:16px 0 0 0;border-bottom: none;" >
                  <div>
                    <p>实际收入</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key09)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>实际成本</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key10)}</span> 万元 </div>
                  </div>
                  <div>
                    <p>实际收支比</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key11)}</span> % </div>
                  </div>
                  <div>
                    <p>利润</p>
                    <div class="dw"> <span class="num">${pricefmt(data[0].key12)}</span> 万元 </div>
                  </div>
                </div>
              </div>
      `
			$('.rwhDetail').html(options)

    }
  })
}

 //成本明细 数据
function getcostBreakdownData() {
  let Tabledata =
    [{key01: '计划', key02: '7788.67', key03: '7788.67', key04: '7788', key05: '7788.67', key06: '7788.67', key07: '788.67', key08: '7788.67', key09: '788.67' },
     {key01: '实际', key02: '5454.23', key03: '5454.23', key04: '5454.23', key05: '5454.23', key06: '5454.23', key07: '5454.23', key08: '5454.23', key09: '5454.23' },
     {key01: '进度', key02: '12', key03: '70', key04: '50', key05: '7', key06: '22', key07: '88', key08: '90', key09: '100' },
    ]
  console.log(Tabledata, '明细表')
  let data = Tabledata
  let cols = [
    [{
        field: 'key01',
        title: '',
      templet: function (d) {
          return `
          <div class="rwh">
            <span>${d.key01}</span> 
          </div>
        `  
        }
      },
      {
        field: 'key02',
        title: '材料',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key02}%"></div>
              </div>
              <div>${d.key02}%</div> 
            </div>`
           } else {
            return `
              <div>
                <span>${d.key02 ? pricefmt(d.key02) : '-'}</span> 
              </div>
            `
           }
          }
      },
      {
        field: 'key03',
        title: '外协',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key03}%"></div>
              </div>
              <div>${d.key03}%</div> 
            </div>`
           } else {
            return `
            <div>
              <span>${d.key03 ? pricefmt(d.key03) : '-'}</span> 
            </div>
            `
           }
        }
      },
      {
        field: 'key04',
        title: '专用',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key04}%"></div>
              </div>
              <div>${d.key04}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key04 ? pricefmt(d.key04) : '-'}</span> 
          </div>
        `}
        }
      },
      {
        field: 'key05',
        title: '事务',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key05}%"></div>
              </div>
              <div>${d.key05}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key05 ? pricefmt(d.key05) : '-'}</span> 
          </div>
        `}
        }
      },
      {
        field: 'key06',
        title: '燃料动力',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key06}%"></div>
              </div>
              <div>${d.key06}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key06 ? pricefmt(d.key06) : '-'}</span> 
          </div>
        `
          }
        }
      },
      {
        field: 'key07',
        title: '工资',
        align: 'right',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key07}%"></div>
              </div>
              <div>${d.key07}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key07 ? pricefmt(d.key07) : '-'}</span> 
          </div>
        `}
        }
      },
      {
        field: 'key08',
        align: 'right',
        title: '折旧',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key08}%"></div>
              </div>
              <div>${d.key08}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key08 ? pricefmt(d.key08) : '-'}</span> 
          </div>
        `}
        }
      },
      {
        field: 'key09',
        align: 'right',
        title: '管理',
        templet: function (d) {
          if (d.key01 == '进度') {
            return `
            <div class="processBar">
              <div class="progress">
               <div class='jindu' style="width:${d.key09}%"></div>
              </div>
              <div>${d.key09}%</div> 
            </div>`
          } else {
            return `
          <div>
            <span>${d.key09 ? pricefmt(d.key09) : '-'}</span> 
          </div>
        `}
        }
      },
     
      // {
      //   field: 'key14',
      //   align: 'right',
      //   title: '结算成本',
      //   width: '10%',
      //   templet: function (d) {
      //     return `
      //     <div class="rwh">
      //       <span>${d.key14 ? pricefmt(d.key14) : 0}</span> 
      //     </div>
      //   `
      //   }
      // },
    ],
  ];
  tableDrawing(data) // 数据传到 table组件
  //表内容
  function tableDrawing(data) {
    layui.use('table', function () {
      let table = layui.table;
      table.render({
        elem: '#newsList',
        cols: cols,
        data: data, // 数据
        limit: limit, // 每页显示的条数
        // height: tableHeight,
        // even: true, //开启隔行背景
        done: function (res, curr, count) {
          var that = this.elem.next();
          res.data.forEach(function (item, index) {
            if (index % 2 == 0) {
              var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FEFBF4");
            } else {
              var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
            }
          })
        }
      });
    })
  }
}

let page = 1;
let limit = 10;
//tab 切换
let tabIndex = 0

let tabs = document.querySelectorAll(".tab")
let tabsList = document.querySelectorAll(".tables-data >div")
// console.log(tabsList)
for (var i = 0; i < tabs.length; i++){
  tabs[i].setAttribute("index", i)
  tabs[i].addEventListener("click", function () {
    for (var i = 0; i < tabs.length; i++){
      tabs[i].classList = "tab"
      tabsList[i].style.display="none"
    }
    this.className = "tab tabActive"
    console.log(this.getAttribute('index'),'*******')
    tabsList[this.getAttribute('index')].style.display="block"
    tabIndex = this.getAttribute('index')
    if (tabIndex == 0) {
      JHSR()
    }
    if (tabIndex == 1) {
      NDSJ()
    }
    if (tabIndex == 2) {
      EMS()
    }
    if (tabIndex == 3) {
      JHZC()
    }
    if (tabIndex == 4) {
      SJZC()
    }
  })
}

//sjsr 切换
let sjsrTabIndex = 0
let sjsrTabs = document.querySelectorAll(".sjsr-tab")
let sjsrTabList = document.querySelectorAll(".sjsrTable > div")
// console.log(sjsrTabList)
for (var i = 0; i < sjsrTabs.length; i++){
  sjsrTabs[i].setAttribute("index", i)
  sjsrTabs[i].addEventListener("click", function () {
    for (var i = 0; i < sjsrTabs.length; i++){
      sjsrTabs[i].classList = "sjsr-tab"
      sjsrTabList[i].style.display = "none"
    }
    this.className = "sjsr-tab sjsr-tab-active"
    console.log(this.getAttribute('index'),'sjsr 切换---index')
    sjsrTabList[this.getAttribute('index')].style.display="block"
    tabIndex = this.getAttribute('index')
    if (tabIndex == 0) {
      NDSJ()
    }
    if (tabIndex == 1) {
      PZLS()
    }
  })
}

//计划收入 数据
function JHSR() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    status: 2,
    chartPage: 80804,
    chartNo: 2,
    pageNum: page,
    pageRowCount:limit
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data,'计划收入 数据')
    let cols = [
      [{
          field: 'key01',
          title: '任务号',
          minWidth:100,
        templet: function (d) {
              return `
            <div class="rwh">
              <span>${d.key01}</span> 
            </div>
          `
          }
        },
        {
          field: 'key02',
          title: '合同编号',
          minWidth:120,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key02}</span> 
            </div>
          `
          }
        },
        {
          field: 'key03',
          title: '甲方单位',
          width: 220,
        },
        {
          field: 'key04',
          title: '合同金额',
          align: 'right',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key05',
          title: '应收金额',
          minWidth:100,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key05 ? pricefmt(d.key05) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key06',
          title: '到款金额',
          align: 'right',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key06 ? pricefmt(d.key06) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key07',
          title: '未到金额',
          align: 'right',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key07 ? pricefmt(d.key07) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key08',
          align: 'left',
          minWidth:150,
          title: '记账凭证号',
        },
        {
          field: 'key09',
          title: '记账金额',
          align: 'right',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key09 ? pricefmt(d.key09) :'-'}</span> 
            </div>
          `
          }
        },
      ],
    ];
    tableDrawing(data) // 数据传到 table组件
    pagesDrawing(data) // 数据传到 分页组件
    //表内容
    function tableDrawing(data) {
      layui.use('table', function () {
        let table = layui.table;
        table.render({
          elem: '#JHSR',
          cols: cols,
          data: data, // 数据
          limit: limit, // 每页显示的条数
          // height: tableHeight,
          // even: true, //开启隔行背景
          done: function (res, curr, count) {
            var that = this.elem.next();
            res.data.forEach(function (item, index) {
              if (index % 2 == 0) {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#F3FCFC");
              } else {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
              }
            })
          }
        });
      })
    }
    //表脚
    function pagesDrawing(data) {
      let totolPage = ''
      if (data.length > 0) {
        totolPage = data[0].key10 ? data[0].key10 : 0
      } else {
        totolPage = 0
      }
      layui.use('laypage', function () {
        let laypage = layui.laypage;
        laypage.render({
          elem: 'JHSRlaypage', //注意，这里的 page 是 ID，不用加 # 号
          count: totolPage, //数据总数，从服务端得到
          theme: '#E8F3FF',
          limit: limit, // 每页条数
          prev: '<em><</em>',
          next: '<em>></em>',
          layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
          jump: function (obj, first) {
            console.log(obj, '第几页 ')
            console.log(obj.curr, '第几页 ')
            //首次不执行
            if (!first) {
              limit = obj.limit;
              numpage(obj.curr, obj.limit) // 分页点击传参 
            }
          }
        });
      })
    };
    //分页
    function numpage(curr, page_count) { // 分页切换-数据请求
      console.log(curr,page_count)
      var obj = {
        username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
        xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
        status: 2,
        chartPage: 80804,
        chartNo: 2,
        pageNum: curr, //页号
        pageRowCount: page_count, //每页多少条
      };
      ApiGet("getdata", obj, function (e) {
        var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
        var chartData = json.items[0].charts;
        let data = chartData[0].data
        console.log(data, '计划收入---分页之后的数据')
        tableDrawing(data);
      });
  
    };
  })
}
//实际收入--年度实际 数据
function NDSJ() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    xm02: localStorage.getItem('pinkYear'),
    status: 2,
    chartPage: 80804,
    chartNo: 3,
    pageNum: page,
    pageRowCount:limit
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data,'实际收入--年度实际 数据')
    let cols = [
      [{
          field: 'key01',
          title: '年',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key01}</span> 
            </div>
          `
          }
        },
        {
          field: 'key02',
          title: '费用类别',
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key02}</span> 
            </div>
          `
          }
        },
        {
          field: 'key03',
          title: '费用名称',
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key03}</span> 
            </div>
          `
          }
        },
        {
          field: 'key04',
          title: '金额',
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
            </div>
          `
          }
        }
      ],
    ];
    tableDrawing(data) // 数据传到 table组件
    pagesDrawing(data) // 数据传到 分页组件
    //表内容
    function tableDrawing(data) {
      layui.use('table', function () {
        let table = layui.table;
        table.render({
          elem: '#NDSJ',
          cols: cols,
          data: data, // 数据
          limit: limit, // 每页显示的条数
          // height: tableHeight,
          // even: true, //开启隔行背景
          done: function (res, curr, count) {
            var that = this.elem.next();
            res.data.forEach(function (item, index) {
              if (index % 2 == 0) {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#F3FCFC");
              } else {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
              }
            })
          }
        });
      })
    }
    //表脚
    function pagesDrawing(data) {
      let totolPage = ''
      if (data.length > 0) {
        totolPage = data[0].key05 ? data[0].key05 : 0
      } else {
        totolPage = 0
      }
      layui.use('laypage', function () {
        let laypage = layui.laypage;
        laypage.render({
          elem: 'NDSJlaypage', //注意，这里的 page 是 ID，不用加 # 号
          count: totolPage, //数据总数，从服务端得到
          theme: '#E8F3FF',
          limit: limit, // 每页条数
          prev: '<em><</em>',
          next: '<em>></em>',
          layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
          jump: function (obj, first) {
            console.log(obj, '第几页 ')
            console.log(obj.curr, '第几页 ')
            //首次不执行
            if (!first) {
              limit = obj.limit;
              numpage(obj.curr, obj.limit) // 分页点击传参 
            }
          }
        });
      })
    };
    //分页
    function numpage(curr, page_count) { // 分页切换-数据请求
      console.log(curr,page_count)
      var obj = {
        username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
        xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
        xm02: localStorage.getItem('pinkYear'),
        status: 2,
        chartPage: 80804,
        chartNo: 3,
        pageNum: curr, //页号
        pageRowCount: page_count, //每页多少条
      };
      ApiGet("getdata", obj, function (e) {
        var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
        var chartData = json.items[0].charts;
        let data = chartData[0].data
        console.log(data, '实际收入--年度实际 ----分页之后的数据')
        tableDrawing(data);
      });
  
    };
  })
}
//实际收入--凭证流水 数据
function PZLS() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    xm02: localStorage.getItem('pinkYear'),
    status: 2,
    chartPage: 80804,
    chartNo: 4,
    pageNum: page,
    pageRowCount:limit
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data,'实际收入--凭证流水 数据')
    let cols = [
      [{
          field: 'key01',
          title: '任务号',
          fixed: 'left',
          width:160,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key01}</span> 
            </div>
          `
          }
        },
        {
          field: 'key02',
          title: '年',
          width:60,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key02}</span> 
            </div>
          `
          }
        },
        {
          field: 'key03',
          title: '月',
          width:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key03 ? pricefmt(d.key03) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key04',
          title: '日',
          width:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key05',
          title: '凭证编号',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key05 ? pricefmt(d.key05) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key06',
          title: '科目编号',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key06 ? pricefmt(d.key06) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key07',
          title: '科目名称',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key07 ? pricefmt(d.key07) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key08',
          title: '属性',
          minWidth:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key08 ? pricefmt(d.key08) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key09',
          title: '事业科研项目编号',
          minWidth:250,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key09 ? pricefmt(d.key09) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key10',
          title: '记账方向',
          minWidth:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key10 ? pricefmt(d.key10) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key11',
          title: '记账金额',
          minWidth:150,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key11 ? pricefmt(d.key11) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key12',
          title: '出库单号/合同号',
          minWidth:140,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key12 ? pricefmt(d.key12) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key13',
          title: '其他标签',
          minWidth:120,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key13 ? pricefmt(d.key13) :'-'}</span> 
            </div>
          `
          }
        },
      ],
    ];
    tableDrawing(data) // 数据传到 table组件
    pagesDrawing(data) // 数据传到 分页组件
    //表内容
    function tableDrawing(data) {
      layui.use('table', function () {
        let table = layui.table;
        table.render({
          elem: '#PZLS',
          cols: cols,
          data: data, // 数据
          limit: limit, // 每页显示的条数
          // height: tableHeight,
          // even: true, //开启隔行背景
          done: function (res, curr, count) {
            var that = this.elem.next();
            res.data.forEach(function (item, index) {
              if (index % 2 == 0) {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#F3FCFC");
              } else {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
              }
            })
          }
        });
      })
    }
    //表脚
    function pagesDrawing(data) {
      let totolPage = ''
      if (data.length > 0) {
        totolPage = data[0].key14 ? data[0].key14 : 0
      } else {
        totolPage = 0
      }
      layui.use('laypage', function () {
        let laypage = layui.laypage;
        laypage.render({
          elem: 'PZLSlaypage', //注意，这里的 page 是 ID，不用加 # 号
          count: totolPage, //数据总数，从服务端得到
          theme: '#E8F3FF',
          limit: limit, // 每页条数
          prev: '<em><</em>',
          next: '<em>></em>',
          layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
          jump: function (obj, first) {
            console.log(obj, '第几页 ')
            console.log(obj.curr, '第几页 ')
            //首次不执行
            if (!first) {
              limit = obj.limit;
              numpage(obj.curr, obj.limit) // 分页点击传参 
            }
          }
        });
      })
    };
    //分页
    function numpage(curr, page_count) { // 分页切换-数据请求
      console.log(curr,page_count)
      var obj = {
        username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
        xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
        xm02: localStorage.getItem('pinkYear'),
        status: 2,
        chartPage: 80804,
        chartNo: 4,
        pageNum: curr, //页号
        pageRowCount: page_count, //每页多少条
      };
      ApiGet("getdata", obj, function (e) {
        var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
        var chartData = json.items[0].charts;
        let data = chartData[0].data
        console.log(data, '实际收入--凭证流水-----分页之后的数据')
        tableDrawing(data);
      });
  
    };
  })
}
//EMS 数据
function EMS() {
  let data = [{ key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  { key01: '2170-01#', key02: '名称1', key03: '2170-01#', key04: '100,000', key05: '单位1', key06: '张三', key07: '-', key08: '10' },
  {key01:'2170-01#',key02:'名称1',key03:'2170-01#',key04:'100,000',key05:'单位1',key06:'张三',key07:'-',key08:'10'}]
let cols = [
  [{
      field: 'key01',
      title: '计划号',
      templet: function (d) {
        return `
        <div class="rwh">
          <span>${d.key01}</span> 
        </div>
      `
      }
    },
    {
      field: 'key02',
      title: '产品名称',
    },
    {
      field: 'key03',
      title: '产品图号',
      templet: function (d) {
        return `
        <div class="rwh">
          <span>${d.key03}</span> 
        </div>
      `
      }
    },
    {
      field: 'key04',
      title: '计划数量',
      align: 'right',
      templet: function (d) {
        return `
        <div class="rwh">
          <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
        </div>
      `
      }
    },
    {
      field: 'key05',
      title: '责任单位',
      align: 'left',
    },
    {
      field: 'key06',
      title: '责任人',
      align: 'left',
    },
    {
      field: 'key07',
      title: '执行完成情况',
      align: 'left',
      templet: function (d) {
        return `
        <div class="rwh">
          <span>${d.key07 ? pricefmt(d.key07) :'-'}</span> 
        </div>
      `
      }
    },
  ],
];
tableDrawing(data) // 数据传到 table组件
pagesDrawing(data) // 数据传到 分页组件
//表内容
function tableDrawing(data) {
  layui.use('table', function () {
    let table = layui.table;
    table.render({
      elem: '#EMS',
      cols: cols,
      data: data, // 数据
      limit: limit, // 每页显示的条数
      // height: tableHeight,
      // even: true, //开启隔行背景
      done: function (res, curr, count) {
        var that = this.elem.next();
        res.data.forEach(function (item, index) {
          if (index % 2 == 0) {
            var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FAF7FE");
          } else {
            var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
          }
        })
      }
    });
  })
}
//表脚
function pagesDrawing(data) {
  let totolPage = ''
  if (data.length > 0) {
    totolPage = data[0].key08 ? data[0].key08 : 0
  } else {
    totolPage = 0
  }
  layui.use('laypage', function () {
    let laypage = layui.laypage;
    laypage.render({
      elem: 'EMSlaypage', //注意，这里的 page 是 ID，不用加 # 号
      count: totolPage, //数据总数，从服务端得到
      theme: '#E8F3FF',
      limit: limit, // 每页条数
      prev: '<em><</em>',
      next: '<em>></em>',
      layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
      jump: function (obj, first) {
        console.log(obj, '第几页 ')
        console.log(obj.curr, '第几页 ')
        //首次不执行
        if (!first) {
          limit = obj.limit;
          numpage(obj.curr, obj.limit) // 分页点击传参 
        }
      }
    });
  })
};
//分页
function numpage(curr, page_count) { // 分页切换-数据请求
  console.log(curr,page_count)
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    status: 2,
    // chartPage: 80801,
    // chartNo: 5,
    pageNum: curr, //页号
    pageRowCount: page_count, //每页多少条
  };
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    var chartData = json.items[0].charts;
    let data = chartData[0].data
    console.log(data, '分页之后的数据')
    tableDrawing(data);
  });

};
  // var obj = {
  //   username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
  //   xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
  //   status: 2,
  //   // chartPage: 80809,
  //   // chartNo: 9,
  //   pageNum: page,
  //   pageRowCount:limit
  // }
  // ApiGet("getdata", obj, function (e) {
  //   var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
  //   // let data = json.items[0].charts[0].data;
  //   // console.log(data, '计划收入 数据')
  // })
}
//计划支出 数据
function JHZC() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    status: 2,
    chartPage: 80804,
    chartNo: 5,
    pageNum: page,
    pageRowCount:limit
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data, '计划支出 数据')
    
    let cols = [
      //1
      [{
        field: 'key01',
        title: '任务号',
        rowspan: 2,
        minWidth:120,
        templet: function (d) {
          return `
            <div class="rwh">
              <span>${d.key01}</span> 
            </div>
          `
        }
      },
      {
        field: 'key02',
        title: '产品名称',
        minWidth:120,
        rowspan: 2,
        templet: function (d) {
          return `
            <div class="name">
              <span>${d.key02}</span> 
            </div>
          `
        }
      },
      {
        field: '',
        title: '基于工艺路线的分类（工艺BOM）',
        colspan: 2,
        align: 'center',
        },
      {
        field: '',
        title: '成本结果/标准成本',
        rowspan: 2,
        width: 160,
        align: 'center',
        templet: function (d) {
          return `
          <div class="rwh">
            <span>${d.key05 ? pricefmt(d.key05) :'-'}</span> 
          </div>
        `
        }
      },
      {
        field: '',
        title: '成本/费用项目',
        colspan: 6,
        align: 'center',
        }],
      //2
        [{
          field: 'key03',
          title: '承担单位（四级）',
          rowspan: 2,
          width:150,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key03 ? pricefmt(d.key03) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key04',
          title: '工序名称',
          rowspan: 2,
          width:150,
          align: 'left',
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
            </div>
          `
          }
        },
        
        {
          field: 'key06',
          title: '原材料成本',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key06 ? pricefmt(d.key06) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key07',
          title: '外部协作成本',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key07 ? pricefmt(d.key07) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key08',
          title: '测试成本',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key08 ? pricefmt(d.key08) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key09',
          title: '工装成本',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key09 ? pricefmt(d.key09) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key10',
          title: '直接人工成本',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key10 ? pricefmt(d.key10) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key11',
          title: '制造费用',
          rowspan: 2,
          width:150,
          align: 'right',
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key11 ? pricefmt(d.key11) :'-'}</span> 
            </div>
          `
          }
          }
        ]
    ];
    tableDrawing(data) // 数据传到 table组件
    pagesDrawing(data) // 数据传到 分页组件
    //表内容
    function tableDrawing(data) {
      layui.use('table', function () {
        let table = layui.table;
        table.render({
          elem: '#JHZC',
          cols: cols,
          data: data, // 数据
          limit: limit, // 每页显示的条数
          done: function (res, curr, count) {
            var that = this.elem.next();
            res.data.forEach(function (item, index) {
              if (index % 2 == 0) {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FEFBF4");
              } else {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
              }
            })
          }
        });
      })
    }
    //表脚
    function pagesDrawing(data) {
      let totolPage = ''
      if (data.length > 0) {
        totolPage = data[0].key12 ? data[0].key12 : 0
      } else {
        totolPage = 0
      }
      layui.use('laypage', function () {
        let laypage = layui.laypage;
        laypage.render({
          elem: 'JHZClaypage', //注意，这里的 page 是 ID，不用加 # 号
          count: totolPage, //数据总数，从服务端得到
          theme: '#E8F3FF',
          limit: limit, // 每页条数
          prev: '<em><</em>',
          next: '<em>></em>',
          layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
          jump: function (obj, first) {
            console.log(obj, '第几页 ')
            console.log(obj.curr, '第几页 ')
            //首次不执行
            if (!first) {
              limit = obj.limit;
              numpage(obj.curr, obj.limit) // 分页点击传参 
            }
          }
        });
      })
    };
    //分页
    function numpage(curr, page_count) { // 分页切换-数据请求
      console.log(curr,page_count)
      var obj = {
        username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
        xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
        status: 2,
        chartPage: 80804,
        chartNo: 5,
        pageNum: curr, //页号
        pageRowCount: page_count, //每页多少条
      };
      ApiGet("getdata", obj, function (e) {
        var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
        var chartData = json.items[0].charts;
        let data = chartData[0].data
        console.log(data, '计划支出-----分页之后的数据')
        tableDrawing(data);
      });
  
    };
  })
}
//实际支出 数据
function SJZC() {
  var obj = {
    username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
    xm02: localStorage.getItem('pinkYear'),
    status: 2,
    chartPage: 80804,
    chartNo: 6,
    pageNum: page,
    pageRowCount:limit
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
    let data = json.items[0].charts[0].data;
    console.log(data, '实际支出 数据')
    let cols = [
      [{
          field: 'key01',
          title: '任务号',
          fixed: 'left',
          width:160,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key01}</span> 
            </div>
          `
          }
        },
        {
          field: 'key02',
          title: '年',
          width:80,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key02}</span> 
            </div>
          `
          }
        },
        {
          field: 'key03',
          title: '月',
          width:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key03 ? pricefmt(d.key03) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key04',
          title: '日',
          width:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key04 ? pricefmt(d.key04) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key05',
          title: '凭证编号',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key05 ? pricefmt(d.key05) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key06',
          title: '科目编号',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key06 ? pricefmt(d.key06) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key07',
          title: '科目名称',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key07 ? pricefmt(d.key07) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key08',
          title: '属性',
          minWidth:80,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key08 ? pricefmt(d.key08) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key09',
          title: '事业科研项目编号',
          minWidth:250,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key09 ? pricefmt(d.key09) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key10',
          title: '记账方向',
          minWidth:50,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key10 ? pricefmt(d.key10) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key11',
          title: '记账金额',
          minWidth:100,
          templet: function (d) {
            return `
            <div class="rwh">
              <span>${d.key11 ? pricefmt(d.key11) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key12',
          title: '出库单号/合同号',
          minWidth:180,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key12 ? pricefmt(d.key12) :'-'}</span> 
            </div>
          `
          }
        },
        {
          field: 'key13',
          title: '其他标签',
          minWidth:120,
          templet: function (d) {
            return `
            <div class="name">
              <span>${d.key13 ? pricefmt(d.key13) :'-'}</span> 
            </div>
          `
          }
        },
      ],
    ];
    tableDrawing(data) // 数据传到 table组件
    pagesDrawing(data) // 数据传到 分页组件
    //表内容
    function tableDrawing(data) {
      layui.use('table', function () {
        let table = layui.table;
        table.render({
          elem: '#SJZC',
          cols: cols,
          data: data, // 数据
          limit: limit, // 每页显示的条数
          done: function (res, curr, count) {
            var that = this.elem.next();
            res.data.forEach(function (item, index) {
              if (index % 2 == 0) {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FEFBF4");
              } else {
                var tr = that.find(".layui-table-box tbody tr[data-index= " + index + "]").css("background-color","#FFF");
              }
            })
          }
        });
      })
    }
    //表脚
    function pagesDrawing(data) {
      let totolPage = ''
      if (data.length > 0) {
        totolPage = data[0].key14 ? data[0].key14 : 0
      } else {
        totolPage = 0
      }
      layui.use('laypage', function () {
        let laypage = layui.laypage;
        laypage.render({
          elem: 'SJZClaypage', //注意，这里的 page 是 ID，不用加 # 号
          count: totolPage, //数据总数，从服务端得到
          theme: '#E8F3FF',
          limit: limit, // 每页条数
          prev: '<em><</em>',
          next: '<em>></em>',
          layout: ['count', 'limit', 'prev', 'page', 'next', 'skip'],
          jump: function (obj, first) {
            console.log(obj, '第几页 ')
            console.log(obj.curr, '第几页 ')
            //首次不执行
            if (!first) {
              limit = obj.limit;
              numpage(obj.curr, obj.limit) // 分页点击传参 
            }
          }
        });
      })
    };
    //分页
    function numpage(curr, page_count) { // 分页切换-数据请求
      console.log(curr,page_count)
      var obj = {
        username: localStorage.getItem('user') ? localStorage.getItem('user') : '',
        xm01: localStorage.getItem('rwh') ? localStorage.getItem('rwh') : '',
        xm02: localStorage.getItem('pinkYear'),
        status: 2,
        chartPage: 80804,
        chartNo: 6,
        pageNum: curr, //页号
        pageRowCount: page_count, //每页多少条
      };
      ApiGet("getdata", obj, function (e) {
        var json = JSON.parse(e.replace(/[\r|\n|\t]/g, ""));
        var chartData = json.items[0].charts;
        let data = chartData[0].data
        console.log(data, '实际支出------分页之后的数据')
        tableDrawing(data);
      });
  
    };
  })
}






$(function () {
  $('.search>div.section2').on('click', '.options div', function (event) {
		event.stopPropagation();
		let options = ''
		let num = '';
		fullRWH = []
		fullRWHText = '';
		$(this).toggleClass('checked')
		if ($(this).hasClass('all')) {
			if ($(this).hasClass('checked')) {
				$(this).removeClass('half')
				$('.search>div.section2 .options div.unit').addClass('checked');
				$('.search>div.section2 .sector div').html('<span>全部</span>')
					fullRWH = localStorage.getItem('newArrfullRWH')
				  fullRWHText = ''
			} else {
				$(this).removeClass('half')
				$('.search>div.section2 .options div.unit').removeClass('checked')
				fullRWH = ''
				fullRWHText = ''
			}
		} else {
			if ($('.search>div.section2 .options div.unit.checked').length == 0) {
				$('.search>div.section2 .options div.all').removeClass('checked')
				$('.search>div.section2 .options div.all').removeClass('half')
				$('.search>div.section2 .sector div').html('')
				fullRWH = ''
				fullRWHText = ''
			} else if ($('.search>div.section2 .options div.unit.checked').length < $(
					'.search>div.section2 .options div.unit').length || !$(
					'.search>div.section2 .options div').eq(0).hasClass('all')) {
				$('.search>div.section2 .options div.all').removeClass('checked')
				$('.search>div.section2 .options div.all').addClass('half')
				$('.search>div.section2 .options div.unit.checked').each(function (index) {
					// console.log($(this))
					fullRWH.push($(this).attr('data-num'))
					fullRWHText += $(this).find('p').text() + ' '
					if (index < 3) {
						let op = `<span>${$(this).find('p').text()}</span>`;
						options += op
					} else {
						num = `<span>+${index - 2}</span>`;
					}

				})
				if (num) {
					options += num
				}
				fullRWH = fullRWH.join(',')
				$('.search>div.section2 .sector div').html(options)
			} else if ($('.search>div.section2 .options div.unit.checked').length == $(
					'.search>div.section2 .options div.unit').length) {
				$('.search>div.section2 .options div.all').addClass('checked')
				$('.search>div.section2 .options div.all').removeClass('half')
				if ($('.search>div.section2 .options div').hasClass('all')) {
					$('.search>div.section2 .sector div').html('<span>全部</span>')
				}
				fullRWH = ''
				fullRWHText = ''
			}
		}
		fullRWHText = fullRWHText.trim()
		localStorage.setItem('rwh', fullRWH);
		localStorage.setItem('rwhText', fullRWHText)
		change()

	})

	$('.search>div.section2').click(function () {
		$('.search>div.section2 .options').toggle()
	})
	$('.search>div.section2').click(function (event) {
		event.stopPropagation();
	})
	$(document).click(function () {
		$('.search>div.section2 .options').hide()
	})

	document.getElementsByClassName('options')[0] ? getDepartment() : ''


  function getDepartment() {
    let fullRWH =[]
		let options = ''
		$.get(`${API_URL}getList/xm`, {}, function (e) {
      console.log(e.items)
      e.items.unshift({ bh: '', rwh: '全部' })
			for (let i = 0; i < e.items.length; i++) {
        fullRWH.push(e.items[i].bh)
        options += `<div class="${e.items[i].rwh == '全部'?'all':'unit'}" data-num="${e.items[i].bh}">
                      <i></i>
                      <p>${e.items[i].rwh}</p>
                    </div>`
      }
			console.log(localStorage.getItem('rwhText'))
			$('.search>div.section2 .sector span').text(e.items[0].rwh)
      $('.search>div.section2 .options').html(options)
      //全部任务号
	    const newArrfullRWH = fullRWH.filter(item => item !== '')
	    localStorage.setItem('newArrfullRWH', newArrfullRWH);
			if (!localStorage.getItem('rwhText')) {
				if (e.items[0].rwh == '全部') {
					$('.search>div.section2 .options div').addClass('checked')
				} else {
					$('.search>div.section2 .options div').eq(0).addClass('checked')
				}
				fullRWH = newArrfullRWH
				fullRWHText = e.items[0].rwh
				localStorage.setItem('rwh', fullRWH);
				localStorage.setItem('rwhText', fullRWHText)
			} else {
				if (localStorage.getItem('rwhText') != '全部') {
					initrwh(e.items)
				} else {
					$('.search>div.section2 .options div').addClass('checked')
				}
			}
		})
		}



	

	function initrwh(data) {
		let rwhText = localStorage.getItem('rwhText').split(' ');
		console.log(rwhText)
		for (let i = 0; i < data.length; i++) {
			for (let j = 0; j < rwhText.length; j++) {
				if (rwhText[j] == data[i].rwh) {
					$('.search>div.section2 .options div').eq(i).addClass('checked')
				}
			}
		}
		let spans = '';
		const nums = rwhText.length>3?3:rwhText.length;
		for (let i = 0; i < nums; i++) {
			spans += `<span>${rwhText[i]}</span>`
		}
		if (rwhText.length > 3) {
			spans += `<span>+${rwhText.length - 3}</span>`
		}
		$('.search>div.section2 .options div.all').addClass('half')
		$('.search>div.section2 .sector div').html(spans)
	}




	

	$('.container .navigation').on('click', '.toggle', function () {
		$('.container .navigation .childUl').hide()
		if (isExpansion) {
			isExpansion = false;
			$('.container .navigation .toggle.expansion').hide();
			$('.container .navigation .toggle.packUp').show();

			$('.container .navigation').attr('class', 'navigation before tran');
			$('.container  .content').removeClass('after')
		} else {
			isExpansion = true;
			$('.container .navigation .toggle.expansion').show();
			$('.container .navigation .toggle.packUp').hide();
			$('.container .navigation').attr('class', 'navigation after tran');
			$('.container  .content').addClass('after')
		}
		localStorage.setItem('isExpansion', isExpansion);
	})

	$('.container .navigation').on('click', '.parentLi img.arrow', function () {
		$(this).parent().next().slideToggle()
	})
	// initNav()
	renewalTime()


	navInt()
})
var pinkYear = localStorage.getItem('pinkYear') ? localStorage.getItem('pinkYear') : new Date().getFullYear();
localStorage.setItem('pinkYear', pinkYear);
document.getElementById('year1') ? layui.use(['laydate'], function (laydate) {
	laydate.render({
		elem: '#year1',
		type: 'year',
		theme: '#165DFF',
		value: pinkYear,
		//,range: true 
		//,trigger: 'click'
		done: function (value, date, endDate) {
			console.log(value, date, endDate);
			pinkYear = value.split('-')[0]

			localStorage.setItem('pinkYear', pinkYear);
			change()
		},
		change: function (value, date, endDate) {
			//this.elem.val(value)
		}
	});
}) : ''